package com.tsunami.authority.enums.auth;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tsunami.base.BaseEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @author lx
 * @date 2024-10-20
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "部门分类状态-枚举")
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum TypeStatus implements BaseEnum {
    /**
     * STUDY="教学相关"
     */
    STUDY("教学相关"),
    /**
     * COMMON="基础相关"
     */
    COMMON("基础相关"),
    /**
     * BETWEEN="兼容相关"
     */
    BETWEEN("兼容相关"),
    ;

    @Schema(description = "描述")
    private String desc;


    public static TypeStatus match(String val, TypeStatus def) {
        for (TypeStatus enm : TypeStatus.values()) {
            if (enm.name().equalsIgnoreCase(val)) {
                return enm;
            }
        }
        return def;
    }

    public static TypeStatus get(String val) {
        return match(val, null);
    }

    public boolean eq(String val) {
        return this.name().equalsIgnoreCase(val);
    }

    public boolean eq(TypeStatus val) {
        if (val == null) {
            return false;
        }
        return eq(val.name());
    }


    @Override
    public String getCode() {
        return BaseEnum.super.getCode();
    }

    @Override
    public String getDesc() {
        return this.desc;
    }
}
